﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml;

namespace Summerset.Isbndb.Publishers
{
    /// <summary>
    /// Represents a category that a <see cref="PublisherElement"/> has publications listed in.
    /// This information must be explicitly requested using the <see cref="PublishersArgs.Results.categories"/> argument
    /// when creating a new <see cref="PublishersRequest"/>.
    /// </summary>
    public sealed class PublisherElementCategory : ResponseElementChildBase
    {
        /* Example Element:
         * <Category category_id="alphabetically.publishers.o.r">Publishers, 'OR'</Category>
         */

        #region Constructor + Overridden Properties
        
        /// <summary>
        /// Initializes a new instance of the <see cref="PublisherElementCategory"/> class.
        /// </summary>
        /// <param name="element">The xml element containing the underlying data for this instance.</param>
        public PublisherElementCategory(XmlElement element)
            : base(element) { }

        /// <summary>
        /// Gets the xml element name that must be passed to this class's constructor.
        /// </summary>
        protected override string ExpectedElementName
        {
            get { return "Category"; }
        }

        #endregion
        #region Properties

        /// <summary>
        /// Gets this ISBNdb.com-specific ID for the category.  This can be used to request
        /// further details about the category from the categories collection.
        /// </summary>
        public string CategoryId
        {
            get { return _element.Attributes["category_id"].Value; }
        }

        /// <summary>
        /// Gets a friendly-name for this category.  This value can be displayed to users.
        /// </summary>
        public string Text
        {
            get { return _element.InnerText; }
        }

        #endregion
    }
}
